<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class UserBlock extends BaseAction {
    
    function leftBlock() {
        $this->render(null,'block');
    }

    function urlBlock(){
        $uid    = $_SESSION['user']['id'];
        $rs     = DAO_Finder::find(DB_URL, array('uid'=>$uid), 'id,uid,uhash,sina_url,tencent_url,title,total_pv,total_ip,url','id desc', '0,10');
        //print_r($rs);
        $arr    = array();
        if($rs) {
            $log_time   = date('Ymd');
            foreach ($rs as $k => $v) {
                $uhash  = $v->getUhash();
                $ip    = DAO_Finder::findOne(DB_COUNT_IP, array('uhash'=>$uhash), 'log_time', 'id desc');
                $pv    = DAO_Finder::findOne(DB_COUNT_PV, array('uhash'=>$uhash), 'log_time', 'id desc');
                $tmp    = $v->getArray();
                if(strlen($tmp['url']) > 40) {
                    $tmp['url'] = substr($tmp['url'], 0, 40).'...';
                }
                //获取今日ip
                if(!$ip){
                    $tmp['ip']  = 0;
                }else{
                    $tmp['ip'] = $ip->getLogTime();
                }

                //获取pv
                if(!$pv){
                    $tmp['pv']  = 0;
                }else{
                    $tmp['pv'] = $pv->getLogTime();
                }
                $arr[]  = $tmp;
                unset($tmp);
            }
            $_SESSION['cache']['my_url_list']    = $arr;
        }
        $this->set('arr', $arr);
        $this->render(null,'block');
    }
}
?>
